package com.boomsecret.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

/**
 * Created by jack on 2018/1/9.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class OtherPerson implements Externalizable {

    private int age;
    private String username;

    public void writeExternal(ObjectOutput out) throws IOException {
        out.writeInt(age);
        out.writeObject(username);
    }

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        this.age = in.readInt();
        this.username = (String) in.readObject();
    }
}
